package com.mycode.controller;

import com.mycode.domain.Payment;
import com.mycode.domain.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Zengsh123 on 2020/3/9.
 */
@RestController
public class ConsumerController {
    private static final String URI = "http://cloud-provider-payment";

    private final RestTemplate restTemplate;
    @Autowired
    public ConsumerController(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    @GetMapping("/consumer/payment/zk/{id}")
    public ResponseResult<Payment> get(@PathVariable("id") Long id){
        return restTemplate.getForObject(URI + "/payment/zk/" + id, ResponseResult.class);
    }
}
